#include "tuya_cloud_types.h"
#include "tal_api.h"
#include "tkl_output.h"
#include "tkl_pwm.h"
#include "led.h"

static THREAD_HANDLE gadgets_handle;

static void __gadgets_task(void *param)
{
    OPERATE_RET rt = OPRT_OK;

    while (1) {
        /*Frequency, duty cycle settings*/
		led_loop();

		tal_system_sleep(GADGET_TASK_PERIOD);
    }

__EXIT:
    PR_NOTICE("gadgets task is finished, will delete");
    tal_thread_delete(gadgets_handle);
    return;
}


int gadgets_init(void)
{
	OPERATE_RET rt = OPRT_OK;

	/* a pwm thread */
	THREAD_CFG_T gadgets_param = {.priority = THREAD_PRIO_0, .stackDepth = 4096, .thrdname = "gadgets_task"};
	TUYA_CALL_ERR_LOG(tal_thread_create_and_start(&gadgets_handle, NULL, NULL, __gadgets_task, NULL, &gadgets_param));

	return 0;
}
